var e = getApp(), t = "";

Component({
    properties: {
        prop_goods_info: {
            type: null
        },
        goodsId: {
            type: Number
        },
        goodsType: {
            type: String
        },
        hoet: {
            type: null
        }
    },
    data: {
        goodsInfo: {},
        rechargeType: {},
        rechargeItem: {},
        rechargeSpecId: 0,
        displayOptions: [],
        optionsId: 0,
        show1: !1,
        service_QRcode: "",
        service_mobile: "",
        cservice: "",
        mobile: "",
        account: "",
        mobile_disabled: !1,
        bannerUrl: "",
        posterShow: !1
    },
    ready: function() {
        t = "";
        var e = this.properties.prop_goods_info, o = {}, i = this.data.goodsInfo = e.get_goods, a = i.has_many_specs[0];
        this._handClickSpecs(a.specitem[0]), o.goodsInfo = i, o.rechargeType = a, e && e.plugin && e.plugin.oilRechargeGoods && (o.bannerUrl = e.plugin.oilRechargeGoods.banner), 
        e.customer_service && (o.service_QRcode = e.customer_service.service_QRcode, o.service_mobile = e.customer_service.service_mobile, 
        o.cservice = e.customer_service.cservice), this.setData(o);
    },
    methods: {
        handClickSpecs: function(e) {
            var t = e.currentTarget.dataset.item;
            this._handClickSpecs(t);
        },
        _handClickSpecs: function(e) {
            if (this.data.rechargeSpecId != e.id) {
                for (var t = this.data.goodsInfo.has_many_options, o = [], i = 0; i < t.length; i++) t[i].specs.indexOf(e.id) >= 0 && o.push(t[i]);
                this.setData({
                    rechargeSpecId: e.id,
                    rechargeItem: e,
                    displayOptions: o,
                    optionsId: 0
                });
            }
        },
        handClickOptions: function(e) {
            var t = e.currentTarget.dataset.item;
            this.setData({
                optionsId: t.id
            });
        },
        gotoDetailV2: function(e) {
            var t = e.currentTarget.dataset.id;
            wx.navigateTo({
                url: "/packageA/detail_v2/detail_v2?id=" + t
            });
        },
        gotoChat: function(t) {
            var o = t.currentTarget.dataset.cservice + "&goods_id=" + this.data.goodsId;
            wx.navigateTo({
                url: o,
                fail: function(t) {
                    e.tips("客服路由出错");
                }
            });
        },
        setCserviceFlag: function() {
            this.setData({
                show1: !this.data.show1
            });
        },
        gotoOrderList: function() {
            wx.navigateTo({
                url: "/packageA/member/myOrder_v2/myOrder_v2"
            });
        },
        gotoIndex: function() {
            wx.reLaunch({
                url: "/packageG/index/index"
            });
        },
        setPosterShow: function() {
            this.setData({
                posterShow: !0
            });
        },
        setTopping: function() {
            wx.pageScrollTo({
                scrollTop: 0
            });
        },
        getMobileByAccount: function(o) {
            var i = this;
            if (t != this.data.account) {
                var a = e.getNetAddresss("plugin.oil-recharge.frontend.index.getMobileByAccount");
                e._postNetWork({
                    url: a,
                    data: {
                        account: this.data.account
                    },
                    success: function(a) {
                        var s = a.data;
                        if (1 != s.result) return e.tips(s.msg);
                        var r = s.data.mobile;
                        "" == r ? i.setData({
                            mobile_disabled: !1
                        }) : i.setData({
                            mobile_disabled: !0,
                            mobile: r
                        }), t = i.data.account, 1 === o && i.gotoGoodsOrder();
                    }
                });
            } else 1 === o && this.gotoGoodsOrder();
        },
        sendRecharge: function() {
            var t = this.data, o = t.mobile, i = (t.goodsId, t.optionsId);
            if (!o) return e.tips("请输入充值手机号码！"), !1;
            return /^[1][0-9]{10}$/.test(o) ? i <= 0 ? e.tips("请选择规格ID") : void this.getMobileByAccount(1) : (e.tips("请输入正确的充值手机号码！"), 
            !1);
        },
        gotoGoodsOrder: function() {
            var e = this.data, t = e.mobile, o = e.goodsId, i = e.optionsId, a = e.account;
            wx.navigateTo({
                url: "/packageD/buy/myOrder_v2/myOrder_v2?tag=-2&total=1&&goodsId=" + o + "&optionsId=" + i + "&oil_mobile=" + t + "&oil_account=" + a
            });
        }
    }
});